home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / basic / PureBasic.lha / PureBasic_Demo / PureBasic / Examples / FullVersion_Sources / Sound.pb < prev    next >
Encoding:
Text File  |  2000-03-19  |  2.2 KB  |  145 lines

  1.  
  2. ; *********************************
  3. ;
  4. ; Sound example file for PureBasic
  5. ;
  6. ; © 1999 - Fantaisie Software -
  7. ;
  8. ; *********************************
  9.  
  10.  
  11. #SOUNDS=3
  12.  
  13.  
  14.   If InitSound(#SOUNDS)
  15.  
  16.     PrintN("4 Sound Object is Allocated.")
  17.  
  18.     If LoadSound(0,"PureBasic:Examples/Data/Bump.IFF")
  19.       PrintN("Loading Sound.")
  20.     Else
  21.       PrintN("Can't find 'PureBasic:Examples/Data/Bump.IFF'")
  22.     EndIf
  23.  
  24.  
  25.     If DecodeSound(1,?sound)
  26.       PrintN("Decode Sound.")
  27.     EndIf
  28.  
  29.  
  30.     If CreateSound(2,100)
  31.       PrintN("Create Sound.")
  32.  
  33.       len.l=GetSoundLength(2) : c=0
  34.  
  35.       Repeat
  36.  
  37.         If c & 1
  38.           PokeSoundData(2,c,127)
  39.         Else
  40.           PokeSoundData(2,c,128)
  41.         EndIf
  42.  
  43.         c=c+1
  44.       Until c = len
  45.  
  46.       For c=0 To 99 Step 11
  47.         Print ("Sound data nr.") : PrintNumber(c)
  48.         Print(" = ") : PrintNumberN(PeekSoundData(2,c))
  49.       Next
  50.  
  51.       PrintN("")
  52.  
  53.       SetSoundPeriod(2,5000)
  54.       SetSoundVolume(2,64)
  55.       SetSoundChannels(2,15)
  56.  
  57.       If CopySound(2,3)
  58.         PrintN("Copy Sound.")
  59.       EndIf
  60.  
  61.     EndIf
  62.  
  63.  
  64.     chan.w=AllocateSoundChannels(15)
  65.     Print("Allocated channels = ") : PrintNumberN(chan)
  66.  
  67.     If chan
  68.  
  69.       PrintN("Playing Sound 0.")
  70.       PlaySound(0,-1)
  71.       Gosub LMB
  72.  
  73.       PrintN("Playing Sound 1.")
  74.       PlaySound(1,5)
  75.       Gosub LMB
  76.  
  77.       PrintN("Playing Sound 3.")
  78.       PlaySound(3,-1)
  79.       Gosub LMB
  80.  
  81.       PrintN("Changeing Period.")
  82.       per.w=5000 : tmp.w=100
  83.  
  84.       For c=0 To 99
  85.  
  86.         VWait()
  87.         per=per+tmp
  88.  
  89.         If per > 9900
  90.           tmp=-100
  91.         EndIf
  92.  
  93.         ChangeSoundPeriod(3,per)
  94.       Next
  95.  
  96.       Gosub LMB
  97.       PrintN("Changeing Volume.")
  98.       vol.w=64 : tmp=-1
  99.  
  100.       For c=0 To 99
  101.  
  102.         VWait()
  103.         vol=vol+tmp
  104.  
  105.         If vol < 15
  106.           tmp=1
  107.         EndIf
  108.  
  109.         ChangeSoundVolume(3,vol)
  110.       Next
  111.  
  112.       Gosub LMB
  113.       StopSound(3)
  114.  
  115.     EndIf
  116.  
  117.     If SaveSound(3,"Ram:Test.IFF")
  118.       PrintN("Saving Sound to RamDisk.")
  119.     EndIf
  120.  
  121.     For c.w=0 To #SOUNDS
  122.       FreeSound(c)
  123.       Print("Deleting Sound Object nr.") : PrintNumberN(c)
  124.     Next c
  125.  
  126.   EndIf
  127.  
  128.   PrintN("End of Program.")
  129.   End
  130.  
  131.  
  132. LMB:
  133.   PrintN(">> Press LMB to Continue <<")
  134.  
  135.   For c=0 to 24
  136.     VWait()
  137.   Next
  138.  
  139.   MouseWait()
  140.   Return
  141.  
  142.  
  143. sound: IncludeBinary "PureBasic:Examples/Data/Jump.IFF"
  144.  
  145.